FROM alpine:3.14.0
COPY run.sh /
 
RUN cd / && \
    sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories && \
    apk update  && \
    apk add build-base curl shadow openssh bash libxml2-dev openssl-dev libjpeg-turbo-dev libpng-dev libxpm-dev freetype-dev gd-dev gettext-dev libmcrypt-dev binutils && \
    addgroup www  && \
    adduser -G www -D -s /sbin/nologin www  && \
    apk add nginx && \
    apk add php7 php7-fpm php7-opcache php7-curl php7-phar php7-gd php7-mbstring php7-mysqli php7-json php7-mcrypt php7-redis php7-pdo php7-openssl php7-dom php7-xml php7-xmlwriter php7-tokenizer php7-xmlreader php7-zip php7-ctype php7-fileinfo php7-ftp  php7-iconv php7-pdo_mysql php7-xmlrpc php7-bcmath php-simplexml && \
    apk del build-base shadow binutils && \
    php -r "copy('https://install.phpcomposer.com/installer', 'composer-setup.php');" && \
    php composer-setup.php && \
    php -r "unlink('composer-setup.php');" && \
    mv composer.phar /usr/local/bin/composer && \
    rm -rf  /var/cache/apk/* && \
    chmod +x /run.sh

COPY nginx/nginx.conf /etc/nginx/nginx.conf
COPY nginx/default.conf /etc/nginx/conf.d/default.conf
COPY php/www.conf /etc/php7/php-fpm.d/www.conf

EXPOSE  80
ENTRYPOINT ["/run.sh"]
